<?php
namespace Service;

use app\common\model\Calendar;

/**
 * 选择选项类
 */
class ChoiceService
{   
    /**
     * 邀约渠道
     */
    public static function channel($ser = -1)
    {
        $channel = [
            0  => '未知',
            1  => '智联招聘-下载',
            2  => '智联招聘-主投',
            3  => 'boss直聘',
            4  => '微信个人号/群',
            5  => '前程无忧-下载',
            6  => '前程无忧-主投',
            7  => '58同城-下载',
            8  => '58同城-主投',
            9  => '青泽科技',
            10 => '社群',
        ];

        if($ser >= 0) return $channel[$ser];
        return $channel;
    }

    /**
     * 性别
     */
    public static function sex($ser = -1)
    {
        $sex = [
            0  => '保密',
            1  => '男',
            2  => '女',
        ];

        if($ser >= 0) return $sex[$ser];
        return $sex;
    }

    /**
     * 考勤记录
     */
    public static function checkOutHeader($month = '')
    {
        if(!$month) $month = date('m');

        $header = [
            '姓名',
            '部门',
            '工号',
            '出勤天数',
            '休息天数',
            '迟到次数',
            '迟到时长',
            '早退次数',
            '早退时长',
            '缺卡次数',
            '旷工天数',
            '请假时长',
        ];

        $calendarList = Calendar::where(['g_month' => $month])->select();

        foreach($calendarList as $info){
            $days = $info['g_days'] . '号';
            if($info['week'] == 6) $days .= '(六)';
            if($info['week'] == 7) $days .= '(日)'; 
            $dateArr[] = $days;
        }

        return array_merge($header, $dateArr);
    }

    /**
     * 考勤状态颜色
     */
    public static function checkStatusColor($text = '')
    {
        $arr = [
            '旷工' => 'FF99CC',
            '缺卡' => 'FF8080',
            '请假' => 'FFCC99',
            '迟到' => 'CCFFCC',
            '早退' => 'FFCC66',
            '外勤' => '99CCFF',
        ];

        if(strstr($text, '旷工') != false){
            return $arr['旷工'];
        }else if(strstr($text, '缺卡') != false){
            return $arr['缺卡'];
        }else if(strstr($text, '请假') != false){
            return $arr['请假'];
        }else if(strstr($text, '迟到') != false){
            return $arr['迟到'];
        }else if(strstr($text, '早退') != false){
            return $arr['早退'];
        }else if(strstr($text, '外勤') != false){
            return $arr['外勤'];
        }
    }

    /**
     * 简历状态
     */
    public static function getResumeStatus($status = 0)
    {
        if($status == 0) return '异常';
        $statusName = [1 => '认领', 2 => '邀约', 3 => '到面', 4 => '通过', 5 => '入职', 6 => '未到面', 7 => '未通过', 8 => '未入职', 9 => '离职', 10 => '退回'];
        return $statusName[$status];
    }
}